<template>
	<view class="content">
		<u-datetime-picker
			:show="showStart"
			v-model="startStamp"
			closeOnClickOverlay
			mode="date"
			@confirm="confirmStart"
			@cancel="showStart = false"
			@close="showStart = false"
		></u-datetime-picker>
		<view class="section-0">
			<view class="section-body">
				<view class="item" v-for="item in board" :key="item.name">
					<view class="shape" v-if="item.right"></view>
					<view class="top">{{item.name}}</view>
					<view class="bottom">{{item.count}}</view>
				</view>
			</view>
		</view>
		<view class="section-1">
			<view class="form">
				<view class="form-item">
					<view class="label">项目名称</view>
					<view class="shape"></view>
					<view class="input">
						<u--input
							placeholderClass="input-placeholder"
							class="input-body"
						    v-model="form.project_name"
						  ></u--input>
					</view>
				</view>
				<!-- <view class="form-item size2">
					<view class="label">时间</view>
					<view class="shape"></view>
					<view class="input">
						<view class="input-body" @click="showStart = true">{{start}}</view>
						<view class="iconfont icon-rili"></view>
					</view>
				</view> -->
				<view class="actions">
					<view class="action" @click="restFrom">
						<text>重</text>
						<text>置</text>
					</view>
					<view class="action search" @click="fetchList">
						<text>查</text>
						<text>询</text>
					</view>
				</view>
			</view>
			<view class="notice">
				<view class="notice-button">一键通知 <text class="iconfont icon-bell"></text></view>
			</view>
			<view class="list">
				<view class="item">
					<view class="name">{{list.project_name}}</view>
					<view class="action">
						<view class="iconfont icon-bell"></view>
					</view>
					<view class="imgs">
						<view class="img disabled">
							<text class="iconfont icon-huixingzhen"></text>
							<text class="label">下载材料</text>
							<text class="iconfont icon-xiangyou1"></text>
						</view>
						<view class="img disabled">
							<text class="iconfont icon-huixingzhen"></text>
							<text class="label">下载会议纪要</text>
							<text class="iconfont icon-xiangyou1"></text>
						</view>
					</view>
				</view>
				<!-- <view class="item" v-for="item in list" :key="item.projectName">
					<view class="name">{{item.project_name}}</view>
					<view class="action">
						<view class="iconfont icon-bell"></view>
					</view>
					<view class="imgs">
						<view class="img disabled">
							<text class="iconfont icon-huixingzhen"></text>
							<text class="label">下载材料</text>
							<text class="iconfont icon-xiangyou1"></text>
						</view>
						<view class="img disabled">
							<text class="iconfont icon-huixingzhen"></text>
							<text class="label">下载会议纪要</text>
							<text class="iconfont icon-xiangyou1"></text>
						</view>
					</view>
				</view> -->
			</view>
		</view>
		
	</view>
</template>

<script>
	import { committeeInfoApi } from '@/api/statistics.js';
	import { mapGetters, mapActions} from 'vuex';
	export default {
		data() {
			return {
				id: '',
				start: '',
				startStamp: 0,
				showStart: false,
				name: '',
				board: [
					{ name: '项目总数', count: 0, right: true },
					{ name: '未提交项目总数', count: 0 },
				],
				list: [],
				form: {
					project_name: '',
				}
			};
		},
		methods: {
			restFrom() {
				for (let key in this.form) {
					this.form[key] = '';
				}
				this.fetchList();
			},
			formatDate(timeStamp) {
				const date =new Date(timeStamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
				const Y = date.getFullYear() +'-';
			    const M = (date.getMonth() +1 <10 ?'0' + (date.getMonth() +1) : date.getMonth() +1) +'-';
			    const D = date.getDate();
			    const h = date.getHours() +':';
			    const m = date.getMinutes() +':';
			    const s = date.getSeconds();
			   	return Y + M + D;  
			},
			confirmStart(val) {
				const timeStamp = val.value;
				this.start = this.formatDate(timeStamp);	
				this.showStart = false;
			},
			async fetchList() {
				uni.showLoading({title: '加载中...'});
				const { data } = await committeeInfoApi({
					...this.form,
					id: this.id
				});
				uni.hideLoading();
				if (data.code === 1 || data.code === 200) {
					this.list = data.data;
					// this.board[0].count = data.data.total.program_total;
					// this.board[1].count = data.data.total.not_sub_total;
				} 
			},
		},
		onLoad(data) {
			const params = JSON.parse(data.params);
			this.id = params.id;
			uni.setNavigationBarTitle({
				title: params.name
			});
		},
		onReady() {
			this.fetchList();
			this.startStamp = (new Date()).valueOf();
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		background-color: #fff;
	}
	.section-1{
		position: relative;
		top: -50rpx;
		z-index: 10;
		background-color: #fff;
		border-top-left-radius: 50rpx;
		border-top-right-radius: 50rpx;
		.notice{
			width: 100%;
			@include clear();
			margin-bottom: 20rpx;
			.notice-button{
				margin-right: 40rpx;
				float: right;
				width: 270rpx;
				height: 79rpx;
				background-color: #ffffff;
				border-radius: 35rpx;
				box-shadow: 0 0 30rpx 8rpx rgba(#bcbcb5, 0.17);
				text-align: center;
				line-height: 79rpx;
				font-size: 26rpx;
				font-weight: normal;
				font-stretch: normal;
				letter-spacing: 0rpx;
				color: #46464a;
				font-weight: bold;
				.iconfont{
					font-size: 32rpx;
					color: #ffde00;
					font-size: 32rpx;
					margin-left: 20rpx;
				}
			}
		}
		
		.list{
			width: 670rpx;
			box-sizing: border-box;
			margin-left: 40rpx;
			.item{
				width: 100%;
				border-bottom: solid 2rpx #f2f2f0;
				font-size: 26rpx;
				padding-left: 35rpx;
				padding-right: 35rpx;
				@include clear();
				box-sizing: border-box;
				.imgs{
					float: left;
					width: 100%;
					
					@include clear();
					padding-bottom: 30rpx;
					.img{
						float: left;
						margin-right: 25rpx;
						width: auto;
						padding: 0 30rpx;
						height: 42rpx;
						background-color: #ffffff;
						border-radius: 21rpx;
						text-align: center;
						line-height: 42rpx;
						font-size: 16rpx;
						font-weight: bold;
						font-stretch: normal;
						line-height: 42rpx;
						letter-spacing: 0rpx;
						color: #1534ce;
						box-shadow: 0 0 30rpx 8rpx rgba(#bcbcb5, 0.17);
						.label{
							margin-left: 10rpx;
							margin-right: 20rpx;
						}
						.iconfont{
							font-size: 16rpx;
							color: #1534ce;
						}
						&:last-child{
							margin-right: 0;
						}
					}
					.disabled{
						
					}
				}
				.name{
					float: left;
					width: 520rpx;
					line-height: 32rpx;
					font-weight: normal;
					font-stretch: normal;
					// text-overflow: ellipsis;
					// overflow: hidden;
					// white-space: nowrap;
					letter-spacing: 2rpx;
					color: #3b3c40;
					padding: 25rpx 0;
				}
				.action{
					float: right;
					font-size: 32rpx;
					color: #ffde00;
					line-height: 82rpx;
				}
			}
		}
		.actions{
			width: 100%;
			height: 50rpx;
			margin-top: 29rpx;
			padding-bottom: 40rpx;
			display: flex;
			justify-content: space-between;
			.action{
				width: 288rpx;
				height: 48rpx;
				background-color: #395cf5;
				border-radius: 20rpx;
				text-align: center;
				line-height: 48rpx;
				font-size: 26rpx;
				font-weight: normal;
				font-stretch: normal;
				color: #ffffff;
				text{
					&:first-child{
						margin-right: 20rpx;
					}
				}
			}
			.search{
				background-color: #1534ce;
			}
		}
		.form{
			width: 100%;
			padding: 0 75rpx;
			padding-top: 40rpx;
			box-sizing: border-box;
			.form-item{
				width: 600rpx;
				height: 48rpx;
				border-radius: 20rpx;
				border: solid 2rpx #1534ce;
				margin: 0 auto;
				margin-bottom: 34rpx;
				@include clear();
				.label{
					float: left;
					width: 134rpx;
					height: 48rpx;
					text-align: center;
					line-height: 44rpx;
					font-size: 26rpx;
					font-weight: normal;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #1534ce;
				}
				.shape{
					width: 3rpx;
					height: 32rpx;
					background-color: #7f98ae;
					float: left;
					margin-top: 8rpx;
				}
				.input{
					float: left;
					width: calc(100% - 134rpx - 3rpx);
					.input-body{
						box-sizing: border-box;
						width: 100%;
						height: 44rpx;
						padding: 0!important;
						border: none;
						padding-left: 30rpx!important;
						padding-right: 30rpx!important;
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						letter-spacing: 0rpx;
						color: rgba(0,0,0,0.7);
					}
					.input-placeholder{
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						letter-spacing: 0rpx;
						color: rgba(0,0,0,0.5);
					}
				}	
			}
			.size2{
				.label{
					width: 77rpx;
				}
				.input{
					width: calc(100% - 77rpx - 3rpx);
					position: relative;
					.iconfont{
						position: absolute;
						right: 25rpx;
						top: 7rpx;
						font-size: 30rpx;
						color: #dad9df;
					}
				}
			}
		}
	}
	.section-0{
		width: 100%;
		background-color: #2e5efe;
		.section-body{
			width: 100%;
			padding-left: 40rpx;
			height: 230rpx;
			padding-right: 40rpx;
			padding-bottom: 50rpx;
			background-color: #1534ce;
			background-size: cover;
			background-repeat: no-repeat;
			border-top-left-radius: 50rpx;
			border-top-right-radius: 50rpx;
			overflow: hidden;
			box-sizing: border-box;
			.item{
				width: 50%;
				float: left;
				display: flex;
				flex-wrap: wrap;
				align-content: space-between;
				padding-top: 40rpx;
				height: 100rpx;
				position: relative;
				.shape{
					width: 4rpx;
					height: 84rpx;
					background-image: linear-gradient(rgba(#3658f2, 0.3) 0%, #3658f2 30%, #3658f2 70%, rgba(#3658f2, 0.3) 100%,);
					position: absolute;
					right: 0;
					top: 48rpx;
				}
				.top{
					width: 100%;
					text-align: center;
					font-size: 16rpx;
					font-weight: normal;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #95c4fa;
				}
				.bottom{
					width: 100%;
					text-align: center;
					font-size: 58rpx;
					font-weight: bold;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #ffde00;
				}
			}
		}
	}
</style>
